package org.bwapi.bridge.model;

import org.bwapi.bridge.swig.bridge;

/**
 * Position
 * 
 * @see <a href="http://code.google.com/p/bwapi/wiki/Misc#Position">Position</a>
 * 
 * @author Chad Retz
 */
public class Position {

	public static final Position INVALID = new Position(bridge.getPositionInvalid());
	public static final Position NONE = new Position(bridge.getPositionNone());
	public static final Position UNKNOWN = new Position(bridge.getPositionUnknown());

	private final org.bwapi.bridge.swig.Position position;
	
	Position(org.bwapi.bridge.swig.Position position) {
		this.position = position;
	}

	public Position() {
		this(new org.bwapi.bridge.swig.Position());
	}

	public Position(TilePosition position) {
		this(new org.bwapi.bridge.swig.Position(position.getPosition()));
	}

	public Position(int x, int y) {
		this(new org.bwapi.bridge.swig.Position(x, y));
	}
	
	org.bwapi.bridge.swig.Position getPosition() {
		return position;
	}

	public boolean opEquals(Position position) {
		return this.position.opEquals(position.getPosition());
	}

	public boolean opNotEquals(Position position) {
		return this.position.opNotEquals(position.getPosition());
	}

	public boolean opLessThan(Position position) {
		return this.position.opLessThan(position.getPosition());
	}

	public Position opPlus(Position position) {
		return new Position(this.position.opPlus(position.getPosition()));
	}

	public Position opMinus(Position position) {
		return new Position(this.position.opMinus(position.getPosition()));
	}

	public Position opAdd(Position position) {
		return new Position(this.position.opAdd(position.getPosition()));
	}

	public Position opSubtract(Position position) {
		return new Position(this.position.opSubtract(position.getPosition()));
	}

	public double getDistance(Position position) {
		return this.position.getDistance(position.getPosition());
	}

	public double getLength() {
		return position.getLength();
	}
	
	//TODO: add util to set int from pointer

	public int x() {
		return position.xConst();
	}

	public int y() {
		return position.yConst();
	}
}
